
package com.jy.wms.web;

import com.jy.wms.common.base.BaseSessionInfo;
import com.jy.wms.common.base.ServiceException;
import com.jy.wms.pojo.SysHz;
import com.jy.wms.service.SysMenuService;
import com.jy.wms.service.WmsOwnerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;

/*
* 货品管理
* 路由页面
* */
@Controller
@RequestMapping("/goods")
public class WmsGoodsRouter {
    //主页面
//    @RequestMapping(value = "/toCkrb")
//    public String toCkrb() {
//        return "ckrb/ckrb";
//    }
    @Autowired
    SysMenuService menuService;
    @Autowired
    WmsOwnerService wmsOwnerService;
    //主页面
    @RequestMapping(value = "/getgoods/{menu}")
    public String getgoods(@PathVariable("menu") String menu, Model model) {
        model.addAttribute("functions",menuService.getFunctions(menu));
        return "base/goods/goodsList";
    }
    // 新增页面
    @RequestMapping(value = "/toGoodAdd")
    public String toGoodAdd(HttpSession session, Model model) throws ServiceException {
        String hzid="";
        String zjfs="";
        List<SysHz> hz = (List) session.getAttribute(BaseSessionInfo.SessionConsignor);//货主
        if (hz.size() > 0) {
            hzid = hz.get(0).getHzid();
            zjfs=  wmsOwnerService.baseSelectByPrimaryKey(hzid).getZjfs();
        }
        model.addAttribute("zjfs",zjfs);
        System.out.println("222222222222");
        return "base/goods/goodsAdd";
    }
    // 新增页面
    @RequestMapping(value = "/toGoodEdit")
    public String toGoodEdit(HttpSession session,String id, Model model) throws ServiceException {
        String hzid="";
        String zjfs="";
        List<SysHz> hz = (List) session.getAttribute(BaseSessionInfo.SessionConsignor);//货主
        if (hz.size() > 0) {
            hzid = hz.get(0).getHzid();
            zjfs=  wmsOwnerService.baseSelectByPrimaryKey(hzid).getZjfs();
        }
        model.addAttribute("zjfs",zjfs);
        model.addAttribute("id",id);
        return "base/goods/goodsEdit";
    }
    // 绑定库位组
    @RequestMapping(value = "/toGoodKwZ")
    public String toGoodKwZ(String id, Model model) {
        model.addAttribute("id",id);
        return "base/goods/goodKwZ";
    }
    // 查看库位
    @RequestMapping(value = "/toGoodLibrary")
    public String toGoodLibrary(String kwzid, Model model) {
        model.addAttribute("kwzid",kwzid);
        return "base/goods/goodsLibrary";
    }
    // 去绑定库位组
    @RequestMapping(value = "/toBlindLibraryGroup")
    public String toBlindLibraryGroup(String hpid, Model model) {
        model.addAttribute("hpid",hpid);
        return "base/goods/blindLibraryGroup";
    }
    // 物料清单
    @RequestMapping(value = "/toGoodsBom")
    public String toGoodsBom(String id, Model model) {
        model.addAttribute("id",id);
        return "base/goods/goodsBom";
    }
//    @RequestMapping(value = "toGoodAdd")
//    public String toGoodAdd(Model model, HttpSession session){
//        return  "goods/goodsAdd";
//    }
}
